home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1999 March / EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso / earcd / devel / wild / include / pypermacro.i < prev    next >
Text File  |  1999-01-01  |  4KB  |  245 lines

  1.         IFND    PYPERMACRO
  2. PYPERMACRO    SET    1
  3. Call    MACRO
  4.     JSR    _LVO\1(a6)
  5.     ENDM
  6.  
  7. Exec    MACRO
  8.     movea.l    4.w,a6
  9.     ENDM
  10.     
  11. mousewait    MACRO
  12. mwa\@        move.w    $dff106,d0
  13.         and.w    #\1,d0
  14.         move.w    d0,$dff180
  15.         btst    #6,$bfe001
  16.         beq.b    mwa\@
  17. mwb\@        move.w    $dff106,d0
  18.         or.w    #\1,d0
  19.         move.w    d0,$dff180
  20.         btst    #6,$bfe001
  21.         bne.b    mwb\@
  22.         ENDM
  23.  
  24. GetTagData    MACRO    ; tag,default,taglist    [A6 must be uty base]
  25.         movea.l    \3,a0
  26.         move.l    #\1,d0
  27.         move.l    #\2,d1
  28.         Call    GetTagData
  29.         ENDM
  30.  
  31. FindGetData    MACRO    ; tag,taglist,faillabel
  32.         movea.l    \2,a0
  33.         move.l    #\1,d0
  34.         Call    FindTagItem
  35.         tst.l    d0
  36.         beq    \3
  37.         movea.l    d0,a0
  38.         movea.l    4(a0),d0
  39.         ENDM
  40.         
  41. FindTag        MACRO    ; tag,taglist
  42.         movea.l    \2,a0
  43.         move.l    #\1,d0
  44.         Call    FindTagItem
  45.         ENDM
  46.  
  47. SetTagData    MACRO    ; tag,value,taglist
  48.         FindTag    \1,\3
  49.         tst.l    d0
  50.         beq.b    .no\@
  51.         movea.l    d0,a0
  52.         move.l    \2,4(a0)
  53. .no\@
  54.         ENDM
  55.         
  56. bxxxm    MACRO    ; \1(bit),\2offset,\3=Ax,\4=xxx
  57.     IFLT    \1-8
  58.     b\4    #\1,\2+3(\3)
  59.     ELSE
  60.     IFLT    \1-16
  61.     b\4    #\1-8,\2+2(\3)
  62.     ELSE
  63.     IFLT    \1-24
  64.     b\4    #\1-16,\2+1(\3)
  65.     ELSE
  66.     IFLT    \1-32
  67.     b\4    #\1-24,\2(\3)
  68.     ELSE
  69.     illegal
  70.     ENDC
  71.     ENDC
  72.     ENDC
  73.     ENDC
  74.     ENDM
  75.  
  76. bclrm    MACRO    
  77.     bxxxm    \1,\2,\3,clr
  78.     ENDM
  79.     
  80. bsetm    MACRO    
  81.     bxxxm    \1,\2,\3,set
  82.     ENDM
  83.  
  84. btstm    MACRO    
  85.     bxxxm    \1,\2,\3,tst
  86.     ENDM
  87.  
  88. bchgm    MACRO    
  89.     bxxxm    \1,\2,\3,chg
  90.     ENDM
  91.     
  92. TRUE    EQU    -1
  93. FALSE    EQU    0    
  94.     
  95. muls64    MACRO
  96.     muls.l    \1,\2:\3
  97.     ENDM
  98.  
  99. divs64    MACRO
  100.     divs.l    \1,\2:\3
  101.     ENDM    
  102.     
  103. mulsn        MACRO    ; 32*32=32 HiPrecision.        \1,\2,\3(skr)
  104.         muls64    \1,\3,\2
  105.         move.w    \3,\2
  106.         swap    \2
  107.         ENDM
  108.  
  109. ; Obsolete: use PyTree instead, wich is faster for big numbers because of a table.
  110. ; If you know your number to be little, you can use this. Or if you need a small
  111. ; routine to stay in cache. Try them, then select.
  112.  
  113. PyRadix        MACRO    ; \1=dx(a^2) \2=dy=a     IF \1<0, returns 0 !!!
  114.         moveq.l    #-1,\2
  115. .subloop\@    addq.l    #2,\2
  116.         sub.l    \2,\1
  117.         bpl.b    .subloop\@
  118.         lsr.l    #1,\2
  119.         ENDM
  120.  
  121. ; PyTree macro: calcs the sqr of a number, using a scalable table.
  122. ; WARNING: NEGATIVE NUMBERS GIVE ABSURDE RESULTS! NO INTERNAL CHECK!
  123. ; Optimization 1. Eliminate cmps, use only a unique sub at start.
  124.  
  125. PyTree    MACRO    ;\1=x \2=Ax pointing to table \3=x^.5(result) \4=skratch
  126.     bra.b    .cyc\@
  127. .jump\@    move.l    (\2),\3
  128.     ble.b    .fnd\@
  129.     lea.l    (\2,\3.l),\2
  130. .cyc\@    move.l    (\2)+,\4
  131.     sub.l    \1,\4
  132.     beq.b    .exact\@
  133.     blt.b    .jump\@
  134.     tst.l    (\2)
  135.     bmi.b    .fnd\@
  136.     addq.l    #8,\2
  137.     bra.b    .cyc\@
  138. .exact\@
  139.     move.l    4(\2),\3
  140.     bra.b    .had\@
  141. .fnd\@    addq.l    #4,\2
  142.     move.l    (\2)+,\3
  143.     beq.b    .had\@
  144.     blt.b    .low\@
  145. .high\@    subq.l    #2,\3
  146.     sub.l    \3,\4
  147.     bgt.b    .high\@
  148.     bra.b    .had\@
  149. .low\@    add.l    \3,\4
  150.     addq.l    #2,\3
  151.     ble.b    .low\@
  152.     subq.l    #2,\3
  153. .had\@    lsr.l    #1,\3
  154.     ENDM
  155.  
  156. *    move.l    #896*896,d0
  157. *    lea.l    Table,a0
  158. *    PyTree    d0,a0,d1,d2
  159. *    rts
  160. *Table    incbin    "ram:pytree.table"
  161.     
  162. ; Tested with 900*900: ok,exact (goes into high cycle)
  163. ; Tested with 900*900+1: ok,same
  164. ; Tested with 895*895: ok,exact (goes into low cycle)
  165. ; Tested with 895*895+1: BAD, gives 896. correct !
  166. ; ReTested with 895*895+1: ok,gives 895
  167. ; ReTested with 895*895: ok,gives 895
  168. ; Tested with 896*896: ok,gives 896, BUT DOES THE low CYCLE! 896 is in the table! must do directly!
  169. ; ReTested with 896*896: ok,does directly.
  170. ; Post-Opt1:
  171. ; ReTested with 896*896: ok,gives 896 (no more directly,table changed.)
  172.  
  173. ; Profiler info: PyTree is faster than PyRadix, MUCH faster, with quite big values 
  174. ; (from 200 and more,...)
  175.  
  176. BrowseList    MACRO    ; \1=Label,\2=Ax \3=ListHeader (loaded by lea.l \3,\2)
  177.         IFNC    '','\3'
  178.         lea.l    \3,\2
  179.         ENDC
  180.         bra    \1_END
  181. \1
  182.         ENDM
  183.  
  184. BrowseListEnd    MACRO    ; \1=Label,\2=Ax
  185. \1_END        TSTNODE    \2,\2
  186.         bne    \1
  187.         ENDM
  188.  
  189. BrowseArray    MACRO    ; \1=Label
  190.         bra    \1_END
  191. \1
  192.         ENDM
  193.  
  194. BrowseArrayEnd    MACRO    ; \1=Label,\2=Ax array,\3=Ax Item, d0 skr !!!
  195. \1_END        movea.l    (\2)+,\3
  196.         move.l    \3,d0
  197.         bne    \1
  198.         ENDM
  199.         
  200. ;----------------- DEBUG MACROS -------------------------------------------------------
  201.  
  202. BeNasty        MACRO
  203. NastyCode    SET    1
  204.         ENDM
  205.  
  206. NoNasty        MACRO
  207. NastyCode    SET    0
  208.         ENDM        
  209. NastyBK        MACRO
  210.         IFD    NastyCode
  211.         IFNE    NastyCode
  212.         illegal
  213.         ENDC
  214.         ENDC
  215.         ENDM
  216.         
  217. ;----------------- stack taglists -------------------------------
  218.  
  219. TagStkGet    MACRO    
  220. STAKKEDTAGS    SET    0
  221.         clr.l    -(a7)
  222.         ENDM
  223.  
  224. TagStk        MACRO    ; \1=tagvalue (without #),\2=tag data (<ea>)
  225. STAKKEDTAGS    SET    STAKKEDTAGS+1
  226.         move.l    \2,-(a7)
  227.         move.l    #\1,-(a7)
  228.         ENDM
  229.  
  230. TagStkAx    MACRO    ;\1=ax
  231.         IFC    '','\1'
  232.         movea.l    a7,a1
  233.         ELSE
  234.         movea.l    a7,\1
  235.         ENDC
  236.         ENDM
  237.         
  238. TagStkPop    MACRO
  239.         IFNE    STAKKEDTAGS
  240.         lea.l    STAKKEDTAGS*8+4(a7),a7
  241.         ENDC
  242.         ENDM
  243.  
  244.         
  245.         ENDC